﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Imaginecup.Recycling.GameMan;
using Imaginecup.recycling.Object.Entity;
using Imaginecup.recycling.Object.Menu;

namespace Imaginecup.gameState.recycling.Sprite
{
    public class ImageToggleSprite : ISprite
    {
        private String m_NoneTextureName;
        private String m_PressTextureName;
        private ObjectInfo m_SpriteInfo;
        private bool m_bFlag = false;

        public ImageToggleSprite(ObjectInfo spriteInfo, String noneTextureName, String pressTextureName)
        {
            m_SpriteInfo = spriteInfo;
            m_NoneTextureName = noneTextureName;
            m_PressTextureName = pressTextureName;
        }

        public void SetButtonFlag(bool flag)
        {
            m_bFlag = flag;
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            Texture2D texture = ResourceManager.GetInstance().GetContent(m_NoneTextureName);
            spriteBatch.Begin();

            spriteBatch.Draw(texture,
                m_SpriteInfo.WorldLocation,
                new Rectangle(0, 0, m_SpriteInfo.FrameWidth, m_SpriteInfo.FrameHeight),
                Color.White);

            if(m_bFlag)
            {
                Texture2D texturePressed = ResourceManager.GetInstance().GetContent(m_PressTextureName);
                spriteBatch.Draw(texturePressed, 
                    m_SpriteInfo.WorldLocation + new Vector2(1, -14), 
                    Color.White);
            }

            spriteBatch.End();
        }

        public ObjectInfo GetInfo()
        {
            return m_SpriteInfo;
        }
    }
}
